package sso.controller;

import bean.UserDTO;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

@Controller
public class ResourceController {


    @RequestMapping(value = "/resource1", method = RequestMethod.GET)
    @ResponseBody
    public UserDTO resource1(HttpServletRequest request) {
        UserDTO user = (UserDTO)request.getAttribute("user");
        System.out.println(user.toString());
        user.setEmail("web2一返回受保护的资源---11111");
        return user;
    }
    @RequestMapping(value = "/resource2", method = RequestMethod.GET)
    @ResponseBody
    public UserDTO resource2(HttpServletRequest request) {
        UserDTO user = (UserDTO)request.getAttribute("user");
        System.out.println(user.toString());
        user.setEmail("web2一返回受保护的资源----22222222");
        return user;
    }
}
